-- Prefan Access Controller
-- Spectate Plugin

if not SERVER then return end

function PAC.Spectate( owner, ply )

	if ply.Spectating then return end
	if owner.Spectating then return end
	
	owner.Weapons = {}
	
	for k,v in pairs( owner:GetWeapons() ) do
	
		table.insert( owner.Weapons, v:GetClass() )
		
	end
	
	owner:StripWeapons()

	owner:Spectate( OBS_MODE_CHASE )
	owner:SpectateEntity( ply )
	
	owner.Spectating = true
	
end
PAC.AddChatCommand( "spectate", "PLAYER", "moderator", PAC.Spectate )

function PAC.UnSpectate( owner )

	if not owner.Spectating then return end
	
	for k,v in pairs( owner.Weapons ) do
		owner:Give( tostring( v ) )
	end		

	owner:UnSpectate()
	
	owner.Spectating = false
	
end
PAC.AddChatCommand( "unspectate", "STRING", "moderator", PAC.UnSpectate )

PAC.AddPlugin( "Spectate", "Spectate people!", "Prefanatic" )
